﻿<view:WindowBase x:Class="MVVMFramework.WPFDemo.Shell"
        x:ClassModifier="internal"
        xmlns:view="clr-namespace:MVVMFramework.View;assembly=MVVMFramework.View"
        xmlns:local="clr-namespace:MVVMFramework.WPFDemo;assembly=MVVMFramework.WPFDemo"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" 
        d:DataContext="{d:DesignInstance Type=local:ShellVM}"
        Title="{Binding Title}"
        Height="400" Width="600"
        Icon="/Images/User16.png"
        WindowStartupLocation="CenterScreen">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <ToolBar>
            <Button Command="{Binding RefreshCommand}">
                <StackPanel Orientation="Horizontal">
                    <Image Source="/Images/Refresh.png"/>
                    <TextBlock Text="Refresh" Margin="4,0,0,0"/>
                </StackPanel>
            </Button>

            <Separator/>

            <Button Command="{Binding InsertCommand}" IsEnabled="{Binding CanInsert}">
                <StackPanel Orientation="Horizontal">
                    <Image Source="/Images/Add.png"/>
                    <TextBlock Text="Insert" Margin="4,0,0,0"/>
                </StackPanel>
            </Button>

            <Button Command="{Binding ChangeCommand}" IsEnabled="{Binding CanChange}">
                <StackPanel Orientation="Horizontal">
                    <Image Source="/Images/Change.png"/>
                    <TextBlock Text="Change" Margin="4,0,0,0"/>
                </StackPanel>
            </Button>

            <Button Command="{Binding DeleteCommand}" IsEnabled="{Binding CanDelete}">
                <StackPanel Orientation="Horizontal">
                    <Image Source="/Images/Delete.png"/>
                    <TextBlock Text="Delete" Margin="4,0,0,0"/>
                </StackPanel>
            </Button>
        </ToolBar>

        <DataGrid AutoGenerateColumns="False" IsReadOnly="True" Grid.Row="1" ItemsSource="{Binding Entities}" SelectedItem="{Binding Entities.Current}">
            <DataGrid.Columns>
                <DataGridTextColumn Header="User" Binding="{Binding UserName}" Width="*"/>
            </DataGrid.Columns>
        </DataGrid>

        <DataGrid AutoGenerateColumns="False" IsReadOnly="True" Grid.Row="2" 
                  ItemsSource="{Binding DependentEntities}"
                  SelectedItem="{Binding DependentEntities.Current}">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Role" Binding="{Binding RoleName}" Width="*"/>
                <DataGridTextColumn Header="Description" Binding="{Binding RoleDescription}" Width="*"/>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</view:WindowBase>